/*
 * TacticaVacia.java
 *
 * Created on 1 de mayo de 2007, 14:15
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package futbol.tacticas.concursantes.qualitycode;

import java.awt.Color;
import java.awt.Graphics;
import java.util.Vector;

import futbol.tacticas.Comando;
import futbol.tacticas.SituacionJugadores;
import futbol.tacticas.concursantes.Tactica;
import futbol.tacticas.concursantes.qualitycode.common.QBall;
import futbol.tacticas.concursantes.qualitycode.ctrlteam.QCtrlTeam;
import futbol.tacticas.concursantes.qualitycode.opponent.QOpponentTeam;

/**
 * 
 * @author Luis Carlos Hernandez Vega.
 *
 * Intente hacer un buen codigo para mostrar pero la falta d tiempo me mato.
 * 
 * Disculpen la mescla de ingles espaol, tengo muchos aos trabajando para gringos.
 *                    
 */
public class QCodeTactica implements Tactica
{
  public static final int FIELD_HEIGHT  = 240;
  public static final int FIELD_WITH    = 320;
  
  
  public static final int FORCE_7_MAX = 7;
  public static final int FORCE_6 = 6;
  public static final int FORCE_5 = 5;
  public static final int FORCE_4_MIN = 4;
  
  public static final int SPEED_MAX = 10 - FORCE_4_MIN;
  public static final int SPEED_MIN = 10 - FORCE_7_MAX;
  
  public static final int INVALID = Integer.MIN_VALUE;
  public static final String NAME = "Quality Code";
  public static final int TEAM_SIZE = 11;
  
  private final QCtrlTeam team = new QCtrlTeam("My");
  private final QOpponentTeam opponent = new QOpponentTeam("You");
  private final QBall ball = new QBall();
  private boolean starting = true;
  
  public QCodeTactica()
  {    
  }
  
//-------------------------------------------------------------------------- Setup
  
  public Color getColor1()
  {
    return Color.WHITE;
  }

  public Color getColor2()
  {
    return Color.WHITE;
  }

  public Color getColorNumero()
  {
    return Color.BLACK;
  }

  public String getNombre()
  {
    return NAME;
  }

//----------------------------------------------------------------------------  
  
  public int getXInicial(int n)
  {
    starting = true;
    return team.getPlayer(n).getStart().x;
  }

  public int getYInicial(int n)
  {
    return team.getPlayer(n).getStart().y;
  }

  public int getFuerza(int n)
  {
    return team.getPlayer(n).getForce();
  }

//----------------------------------------------------------------------------  
  
  public Vector<Comando> getComandos(SituacionJugadores sj)
  {    
    if (starting)
    {
      reiniciar();            
      starting = false;
    }
    
    team.updatePos(sj.getMisJugadores());
    opponent.updatePos(sj.getContrario());
    
    ball.updatePos(sj.getBola());
    return (Vector<Comando>) team.getComandos(sj, opponent, ball);
  }

  private void reiniciar()
  {
    if (ball.getX() != INVALID)
    {
      if (ball.getX() <= -160)
        opponent.incGoals();
      else
        team.incGoals();        
    }
    
    ball.reset();
    opponent.reset();
    team.reset();
  }

  public void pintar(boolean over, Graphics gdb)
  {
    opponent.pintar(over, gdb);
    team.pintar(over, gdb);
  }
}
















